/*********************************************************************************
 * 
 * Author: wujunjie
 * Create Date: 2014-05-10
 * Description:
 *          
 * Revision History:
 *      Date          Author               Description
 * 
*********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataFrameworkAccess;
using Xinkui.Entity.AutoGenerator;
using Xinkui.Common;
namespace Xinkui.DataAccess.AutoGenerator {
    public partial class BuyleadInfoDataAccess {
        public List<BuyleadInfo_Entity> ListLastBuylead(int pageSize) {
            try {
                int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("BuyleadInfo_LastList");
                cmd.SetParameterValue("@PageSize", pageSize);

                List<BuyleadInfo_Entity> pageList = cmd.ExecuteEntityList<BuyleadInfo_Entity>();

                return pageList;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<BuyleadInfo_Entity>(0);

        }

        public List<BuyleadInfo_Entity> ListRelatedBuylead(int pageSize, int categoryId) {
            try {
                int tempRecord = 0;
                DataCommand cmd = DataCommandManager.GetDataCommand("BuyleadInfo_RelatedList");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@CategoryId", categoryId);
                List<BuyleadInfo_Entity> pageList = cmd.ExecuteEntityList<BuyleadInfo_Entity>();

                return pageList;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<BuyleadInfo_Entity>(0);

        }

        public List<BuyleadInfo_Entity> ListBuyleads(int pageIndex, int pageSize, int category, string key, int region, out int total) {
            total = 0;
            try {
                int tempRecord = 0;
                if (pageIndex <= 0) pageIndex = 1;
                DataCommand cmd = DataCommandManager.GetDataCommand("BuyleadInfo_List");
                cmd.SetParameterValue("@where", "");
                cmd.SetParameterValue("@PageSize", pageSize);
                cmd.SetParameterValue("@PageIndex", pageIndex);
                cmd.SetParameterValue("@RecordCount", tempRecord);
                List<BuyleadInfo_Entity> pageList = cmd.ExecuteEntityList<BuyleadInfo_Entity>();
                object cmdGetParameterValue = cmd.GetParameterValue("@RecordCount");
                if (!(cmdGetParameterValue is DBNull)) {
                    total = Convert.ToInt32(cmdGetParameterValue);
                }
                return pageList;
            }
            catch (Exception ex) {
                ExceptionHelper.ProcessException(ex);
            }

            return new List<BuyleadInfo_Entity>(0);
        }



    }
}
